package cn.zhuizikejithreeig.com.brodcat;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

import cn.zhuizikejithreeig.com.passenger.BasicActivity;

/**
 * 自定义检查手机网络状态是否切换的广播接受器
 *
 * @author cj
 *
 */
public class NetBroadcastReceiver extends BroadcastReceiver  {
   private int netWorkState;
    private PrensentView mMianActivty;
   public NetBroadcastReceiver(PrensentView mianActivty){
       this.mMianActivty = mianActivty;
   }

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        // 如果相等的话就说明网络状态发生了变化
        if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
            netWorkState = NetUtil.getNetWorkState(context);
            // 接口回调传过去状态的类型
            System.out.println("动态注册");
            mMianActivty.onNetChange(netWorkState);

        }
    }

}
